********************************************************************************
** 	TITLE: f13_fcs_3outcomes.do

**	PROJECT: IGNITE
** 
**  PURPOSE: Appendix Table XIII: Community Survey Results
********************************************************************************
**	Positive View of Law Enforcement (Cols. 1 & 2), 
**	Engaged in Positive Activities (Cols. 3 & 4), 
**	and Hopeful about the Future (Cols. 5 & 6).
********************************************************************************
		set sortseed 13

	use "$output_data/IGNITE_community_survey_clean.dta", clear

	*Create a variable for survey wave
	gen wave2 = 0
	gen obs2 = _n
	replace wave2 = 1 if obs2 > 84
	
	gen tether = prob_parole
	replace tether = 0 if tether == .

	local outcomes good_thing ffgood_thing selfgood_thing le_positive total_hopeful ff_hopeful_binary self_hopeful_binary 
	
********************************************************************************
*Extensive Margin Regressions
********************************************************************************	
	local controls self_jail_experience c.agemed wave2
	local outcomes le_positive total_hopeful good_thing
	keep if lengthfactor2 != .
//le_positive
	capture est clear
	reg le_positive ignite_expose wave2, r	
	eststo r1
	estadd local cont "$\checkmark$"
	sum le_positive if ignite_expose == 0
	estadd scalar n1 = r(mean)
//good_thing
	reg good_thing ignite_expose wave2, r	
	eststo r3
	estadd local cont "$\checkmark$"
	sum good_thing if ignite_expose == 0
	estadd scalar n1 = r(mean)
//total_hopeful
	reg total_hopeful ignite_expose wave2, r	
	eststo r5
	estadd local cont "$\checkmark$"
	sum total_hopeful if ignite_expose == 0
	estadd scalar n1 = r(mean)	

********************************************************************************
*Length Regressions
********************************************************************************	
//le_positive
	reg le_positive c.ignite_expose##c.lengthfactor2 wave2, r	
	eststo r2
	estadd local cont "$\checkmark$"
	sum le_positive if ignite_expose == 0
	estadd scalar n1 = r(mean)
//good_thing
	reg good_thing c.ignite_expose##c.lengthfactor2 wave2, r	
	eststo r4
	estadd local cont "$\checkmark$"
	sum good_thing if ignite_expose == 0
	estadd scalar n1 = r(mean)
//total_hopeful
	reg total_hopeful c.ignite_expose##c.lengthfactor2 wave2, r	
	eststo r6
	estadd local cont "$\checkmark$"
	sum total_hopeful if ignite_expose == 0
	estadd scalar n1 = r(mean)
			
********************************************************************************
*	Make Table
********************************************************************************
	estout r1 r2 r3 r4 r5 r6 using "${tables}/ignite_fcsv5_3outcomes_nocontrol_01172024.tex", replace ///
			style(tex) nolabel ///
			collabels(none) cells(b(star fmt(%8.3f)) se(par fmt(%8.3f)))  starlevels(* 0.10 ** 0.05 *** 0.01)  ///
			mlabels(none) ///
			keep(ignite_expose c.ignite_expose#c.lengthfactor2) ///
			order(ignite_expose c.ignite_expose#c.lengthfactor2) ///
			varlabel(ignite_expose "IGNITE Exposure" c.ignite_expose#c.lengthfactor2 "IGNITE Exposure $\times$ Months in Jail") ///
			nobaselevels  ///
			label ///
			stats(foo n1 N, fmt(0 %8.3f 0) /// 			
			labels("\hspace{0.5cm}" "Control Mean" ///
			"Observations")) ///
			prehead(%) posthead(%) postfoot(%)
